﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:converters="clr-namespace:Glass.Basics.Converters"
                    xmlns:themes="clr-namespace:Glass.Basics.Styles"
                    xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
                    mc:Ignorable="d">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Glass.Basics;component/Styles/Themes/Brushes.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <converters:IsEqualConverter x:Key="IsEqualConverter" />

    <Style x:Key="FocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.2" />
                                    <VisualTransition From="Pressed" GeneratedDuration="0:0:0.1" To="MouseOver"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)" Storyboard.TargetName="border">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.273"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#647793F7"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#6CFFFFFF"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#63486DEE"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)" Storyboard.TargetName="border">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.033"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)" Storyboard.TargetName="border">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.115"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[5].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#6BA9B9FD"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[5].(GradientStop.Offset)" Storyboard.TargetName="border">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.803"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#644264D6"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)" Storyboard.TargetName="border">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.406"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#64ABBCF9"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#6CFFFFFF"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#637F9BFB"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)" Storyboard.TargetName="border">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.064"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)" Storyboard.TargetName="border">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.233"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[5].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#6BDFE5FF"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[5].(GradientStop.Offset)" Storyboard.TargetName="border">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.655"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#64728EEC"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[4].(GradientStop.Offset)" Storyboard.TargetName="border">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.839"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[4].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="#6BFFFFFF"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates"/>
                            <VisualStateGroup x:Name="ValidationStates"/>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="border" BorderThickness="1,1,1,1" SnapsToDevicePixels="true">
                            <Border.BorderBrush>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#7FB2B2B2" Offset="1"/>
                                    <GradientStop Color="#7FFFFFFF"/>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                                    <GradientStop Color="#334264D6" Offset="0.137"/>
                                    <GradientStop Color="#33FFFFFF" Offset="1"/>
                                    <GradientStop Color="#337793F7" Offset="0.536"/>
                                    <GradientStop Color="#331039C7" Offset="0.183"/>
                                    <GradientStop Color="#6BF3F5FE" Offset="0.937"/>
                                    <GradientStop Color="#6BF3F5FE" Offset="0.937"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type themes:SystemButton}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                        <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type themes:MaximizeButton}" BasedOn="{StaticResource ButtonStyle}">
        <Setter Property="shell:WindowChrome.IsHitTestVisibleInChrome" Value="True" />
        <Setter Property="IsChecked" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=WindowState, Converter={StaticResource IsEqualConverter}, ConverterParameter={x:Static WindowState.Maximized}}" />
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Content">
            <Setter.Value>
                <Rectangle Height="10" Width="10" Fill="{StaticResource Maximize}" />
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Content">
                    <Setter.Value>
                        <Rectangle  x:Name="rectangle" Height="10" Width="12" Fill="{StaticResource Restore}" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type themes:CloseButton}" BasedOn="{StaticResource ButtonStyle}">
        <Setter Property="shell:WindowChrome.IsHitTestVisibleInChrome" Value="True" />
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Content">
            <Setter.Value>
                <Rectangle Height="10" Width="10" Fill="{StaticResource Close}" />
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type themes:MinimizeButton}" BasedOn="{StaticResource ButtonStyle}">
        <Setter Property="shell:WindowChrome.IsHitTestVisibleInChrome" Value="True" />
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Content">
            <Setter.Value>
                <Rectangle Height="10" Width="8" Fill="{StaticResource Minimize}" />
            </Setter.Value>
        </Setter>

    </Style>


    <Style x:Key="BlueWindowStyle"  TargetType="Window">
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="shell:WindowChrome.WindowChrome">
            <Setter.Value>
                <shell:WindowChrome GlassFrameThickness="0" CornerRadius="0" CaptionHeight="30" />
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Window">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <Border 
                                Background="{TemplateBinding Background}" 
                                Margin="{Binding shell:SystemParameters2.WindowNonClientFrameThickness}" Grid.RowSpan="2"
                                >
                            <AdornerDecorator>
                                <ContentPresenter Content="{TemplateBinding Content}" />
                            </AdornerDecorator>

                        </Border>
                        <Border 
                                BorderBrush="{TemplateBinding BorderBrush}"  
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Margin="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowNonClientFrameThickness}" 
                                Grid.RowSpan="2" />
                        <!--CornerRadius="{Binding Source={x:Static SystemParameters.WindowCornerRadius}}"-->
                        <Border 
                                    BorderBrush="#3981C5" 
                                    BorderThickness="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowResizeBorderThickness}" Grid.RowSpan="2">
                        </Border>
                        <Border Height="{x:Static SystemParameters.WindowCaptionHeight}" 
                                    Margin="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowResizeBorderThickness}" 
                                    Grid.Row="0" Background="#6791F9" >
                            <!--<Border.CornerRadius>
                                    <Binding 
                                            Converter="{StaticResource CornerRadiusMultiplier}"
                                            Source="{x:Static SystemParameters.WindowCornerRadius}">
                                        <Binding.ConverterParameter>
                                            <CornerRadius>0,0,0,0</CornerRadius>
                                        </Binding.ConverterParameter>
                                    </Binding>
                                </Border.CornerRadius>-->
                            <Grid Margin="0,0,0,0">
                                <StackPanel Orientation="Horizontal">
                                    <themes:SystemButton >
                                        <Image Source="{TemplateBinding Icon}" />
                                    </themes:SystemButton>
                                </StackPanel>
                                <TextBlock VerticalAlignment="Center" Text="MainWindow" HorizontalAlignment="Center" FontSize="16" >
                                    <TextBlock.Effect>
                                        <DropShadowEffect Color="#FFFEFFFB" ShadowDepth="0" Opacity="0.995" BlurRadius="6"/>
                                    </TextBlock.Effect>
                                </TextBlock>
                                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,0,10,0"  >
                                    <themes:MinimizeButton Width="25" />
                                    <themes:MaximizeButton Width="25" />
                                    <themes:CloseButton Width="45" VerticalAlignment="Top" Height="20"/>
                                </StackPanel>
                            </Grid>
                        </Border>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


</ResourceDictionary>
